import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_app/BaseMaterialWidget.dart';
import 'package:flutter_app/page_ten/Product.dart';
import 'package:flutter_app/page_ten/RouteDetail.dart';

class RouteDemo2 extends BaseMaterialWidget {
  List<Product> products;

  @override
  Widget buildContent(BuildContext context) {
    return ListView.builder(
        itemCount: products.length,
        itemBuilder: (context, index) {
          return ListTile(
            title: Text(products[index].name),
            onTap: () async {
              final result = await Navigator.push(
                  context,
                  MaterialPageRoute(
                      builder: (context) => RouteDetail(products[index])));
              Scaffold.of(context).showSnackBar(SnackBar(
                content: Text("$result"),
              ));
            },
          );
        });
  }

  @override
  String getTitle() {
    return '页面发送数据';
  }

  RouteDemo2() {
    products = List.generate(20, (i) => Product('商品 $i', '这是商品$i的详情'));
  }
}
